#ifndef __TCPCONNECTION_HPP__
#define __TCPCONNECTION_HPP__

#include "Socket.hpp"
#include "SocketIO.hpp"
#include "InetAddress.hpp"


namespace wd{
class EventLoop;
class TcpConnection{
public:
    TcpConnection(int clientfd, EventLoop * eventloop);
    /* string receive(); */
    int receive(Packet & packet);
    void send(const string &);
    bool isClose() const;

    void sendInLoop(const string & msg);
    void sendInLoop(const TLV & tlv);
    
    void set_pwdp(string pwdp);
    string get_pwdp();

private:
    struct sockaddr_in getlocalAddr();
    struct sockaddr_in getpeerAddr();

private:
    Socket _sock;
    SocketIO _sockio;

    InetAddress _localAddr;
    InetAddress _peerAddr;

    EventLoop * _eventloop;
    string _pwdp;
};



}


#endif // __TCPCONNECTION_HPP__

